<template>
  <div class="login-panel">
    <h1 class="title">后台管理系统</h1>
    <el-tabs type="border-card" v-model="currentTab" :stretch="true">
      <el-tab-pane name="userPanel">
        <template #label>
          <span>
            <i class="el-icon-user-solid"></i>
            账号登录
          </span>
        </template>

        <login-account ref="accountRef" />
      </el-tab-pane>

      <el-tab-pane name="mobilePanel">
        <template #label>
          <span>
            <i class="el-icon-mobile"></i>
            手机登录
          </span>
        </template>

        <login-mobile></login-mobile>
      </el-tab-pane>
    </el-tabs>

    <div class="account-control">
      <el-checkbox v-model="isKeepPassword">记住密码</el-checkbox>
      <el-link type="primary">忘记密码</el-link>
    </div>
    <el-button type="primary" class="login-button" @click="handleLoginClick">登 录</el-button>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue'
import { ElTabs, ElTabPane, ElCheckbox, ElLink, ElButton } from 'element-plus'
import loginAccount from './login-account.vue'
import loginMobile from './login-mobile.vue'

export default defineComponent({
  components: { ElTabs, ElTabPane, loginAccount, loginMobile, ElCheckbox, ElLink, ElButton },
  setup() {
    const currentTab = ref('userPanel')
    const isKeepPassword = ref(false)
    const accountRef = ref<InstanceType<typeof loginAccount>>()

    const handleLoginClick = () => {
      accountRef.value?.doLogin(isKeepPassword.value)
    }

    return { currentTab, isKeepPassword, handleLoginClick, accountRef }
  }
})
</script>
<style scoped lang="less">
.login-panel {
  width: 320px;
  margin-bottom: 300px;
}

.title {
  text-align: center;
}

.account-control {
  display: flex;
  justify-content: space-between;
}

.login-button {
  width: 100%;
  margin-top: 10px;
}
</style>
